Index: question/editlib.php =================================================================== RCS file: /cvsroot/moodle/moodle/question/editlib.php,v retrieving revision 1.93 diff -u -r1.93 editlib.php --- question/editlib.php 10 Sep 2008 05:26:35 -0000 1.93 +++ question/editlib.php 19 Nov 2008 03:03:16 -0000 @@ -158,7 +158,7 @@ $straddquestions = get_string("addquestions", "quiz"); $strimportquestions = get_string("importquestions", "quiz"); $strexportquestions = get_string("exportquestions", "quiz"); - $strnoquestions = get_string("noquestions", "quiz"); + $strnoquestions = get_string("noquestionsincategory", "quiz"); $strselect = get_string("select", "quiz"); $strselectall = get_string("selectall", "quiz"); $strselectnone = get_string("selectnone", "quiz"); @@ -244,7 +244,7 @@ list($usql, $params) = $DB->get_in_or_equal($categorylist_array); if (!$totalnumber = $DB->count_records_select('question', "category $usql AND parent = '0' $showhidden", $params)) { echo "

"; - print_string("noquestions", "quiz"); + echo $strnoquestions; echo "

"; return; } @@ -255,14 +255,13 @@ if (!$questions = $DB->get_records_select('question', "category $usql AND parent = '0' $showhidden", $params, $sortorderdecoded, '*', 0, $perpage)) { // There are no questions at all echo "

"; - print_string("noquestions", "quiz"); + echo $strnoquestions; echo "

"; return; } } print_paging_bar($totalnumber, $page, $perpage, $pageurl, 'qpage'); - echo question_sort_options($pageurl, $sortorder); @@ -397,15 +396,21 @@ function question_sort_options($pageurl, $sortorder){ global $USER; //sort options - $html = "
"; - $html .= '
'; + $html = "
"; + // POST method should only be used for parameters that change data + // or if POST method has to be used, the user must be redirected immediately to + // non-POSTed page to not break the back button + $html .= ''; $html .= '
'; $html .= ''; $html .= $pageurl->hidden_params_out(array('qsortorder')); - $sortoptions = array('alpha' => get_string("sortalpha", "quiz"), - 'typealpha' => get_string("sorttypealpha", "quiz"), - 'age' => get_string("sortage", "quiz")); - $html .= choose_from_menu ($sortoptions, 'qsortorder', $sortorder, false, 'this.form.submit();', '0', true); + //choose_from_menu concatenates the form name with + //"menu" so the label is for menuqsortorder + $sortoptions = array('alpha' => get_string("qname", "quiz"), + 'typealpha' => get_string("qtypename", "quiz"), + 'age' => get_string("age", "quiz")); + $a = choose_from_menu ($sortoptions, 'qsortorder', $sortorder, false, 'this.form.submit();', '0', true); + $html .= ''; $html .= ''; $html .= '
'; $html .= "\n"; Index: question/question.php =================================================================== RCS file: /cvsroot/moodle/moodle/question/question.php,v retrieving revision 1.52 diff -u -r1.52 question.php --- question/question.php 6 Jun 2008 14:43:15 -0000 1.52 +++ question/question.php 19 Nov 2008 03:03:16 -0000 @@ -24,6 +24,7 @@ $movecontext = optional_param('movecontext', 0, PARAM_BOOL);//switch to make question //uneditable - form is displayed to edit category only $returnurl = optional_param('returnurl', 0, PARAM_LOCALURL); +$appendqnumstring = optional_param('appendqnumstring', '', PARAM_ALPHA); $inpopup = optional_param('inpopup', 0, PARAM_BOOL); @@ -132,6 +133,8 @@ if ($formeditable && $id){ $toform->categorymoveto = $toform->category; } + +$toform->appendqnumstring = $appendqnumstring; $toform->returnurl = $returnurl; $toform->movecontext = $movecontext; if ($cm !== null){ @@ -186,10 +189,14 @@ notify(get_string('changessaved'), ''); close_window(3); } else { + if($appendqnumstring){ + $returnurl_object=new moodle_url($returnurl); + $returnurl=$returnurl_object->out(false,array($appendqnumstring=>($question->id), "sesskey"=>sesskey(), "cmid"=>$cmid)); + } redirect($returnurl); } } else { - $nexturlparams = array('returnurl'=>$returnurl); + $nexturlparams = array('returnurl'=>$returnurl, 'appendqnumstring'=>$appendqnumstring); if (isset($fromform->nextpageparam) && is_array($fromform->nextpageparam)){ $nexturlparams += $fromform->nextpageparam;//useful for passing data to the next page which is not saved in the database } Index: question/category_class.php =================================================================== RCS file: /cvsroot/moodle/moodle/question/category_class.php,v retrieving revision 1.44 diff -u -r1.44 category_class.php --- question/category_class.php 23 Oct 2008 09:23:52 -0000 1.44 +++ question/category_class.php 19 Nov 2008 03:03:16 -0000 @@ -12,6 +12,7 @@ require_once("$CFG->libdir/listlib.php"); require_once("$CFG->dirroot/question/category_form.php"); +require_once("$CFG->dirroot/question/category_form_randomquestion.php"); require_once('move_form.php'); class question_category_list extends moodle_list { @@ -135,6 +136,10 @@ * @var question_category_edit_form Object representing form for adding / editing categories. */ var $catform; + /** + * @var question_category_edit_form_randomquestion Object representing simplified form for adding a category in order to add it into a quiz as a random question. + */ + var $catform_rand; /** * Constructor @@ -197,8 +202,10 @@ list($paged, $count) = $this->editlists[$key]->list_from_records($paged, $count); } $this->catform = new question_category_edit_form($this->pageurl, compact('contexts', 'currentcat')); + $this->catform_rand = new question_category_edit_form_randomquestion($this->pageurl, compact('contexts', 'currentcat')); if (!$currentcat){ $this->catform->set_data(array('parent'=>$defaultcategory)); + $this->catform_rand->set_data(array('parent'=>$defaultcategory)); } } /** @@ -217,6 +224,16 @@ echo '
'; } + /** + * Displays the user interface + * + */ + function display_randomquestion_user_interface() { + + /// Interface for adding a new category: + $this->output_new_randomquestion_table(); + + } /** * Outputs a table to allow entry of a new category @@ -225,6 +242,13 @@ $this->catform->display(); } + /** + * Outputs a table to allow entry of a new category + */ + function output_new_randomquestion_table() { + $this->catform_rand->display(); + } + /** * Outputs a list to allow editing/rearranging of existing categories @@ -278,6 +302,8 @@ $category->categoryheader = $this->str->edit; $this->catform->set_data($category); $this->catform->display(); + $this->catform_rand->set_data($category); + $this->catform_rand->display(); } else { print_error('invalidcategory', '', '', $categoryid); } @@ -369,7 +395,7 @@ /** * Creates a new category with given params */ - public function add_category($newparent, $newcategory, $newinfo) { + public function add_category($newparent, $newcategory, $newinfo, $return=false) { global $DB; if (empty($newcategory)) { print_error('categorynamecantbeblank', 'quiz'); @@ -391,10 +417,14 @@ $cat->info = $newinfo; $cat->sortorder = 999; $cat->stamp = make_unique_id_code(); - if (!$DB->insert_record("question_categories", $cat)) { + if (!$categoryid=$DB->insert_record("question_categories", $cat)) { print_error('cannotinsertquestioncate', 'question', '', $newcategory); } else { - redirect($this->pageurl->out());//always redirect after successful action + if($return){ + return $categoryid; + }else{ + redirect($this->pageurl->out());//always redirect after successful action + } } } Index: theme/standard/styles_color.css =================================================================== RCS file: /cvsroot/moodle/moodle/theme/standard/styles_color.css,v retrieving revision 1.188 diff -u -r1.188 styles_color.css --- theme/standard/styles_color.css 18 Nov 2008 07:10:01 -0000 1.188 +++ theme/standard/styles_color.css 19 Nov 2008 03:03:17 -0000 @@ -1091,6 +1091,73 @@ #mod-quiz-report .negcovar{ border :medium solid pink; } + +#mod-quiz-edit .questionbankwindow div.header{ +/*this color might need to be theme-specific, +but in terms of usability, as testing showed, +//TODO: add url +it must be ensured that the question +bank window's title is prominent enough*/ + background-color:#009; + color:#fff; + background-image:none; +} + +#mod-quiz-edit div.question div.content div.points, + #mod-quiz-edit div.question div.content div.qorder{ + background-color:#ddf; +} + +#mod-quiz-edit div.quizpage .pagecontent .pagestatus{ + background-color:#eee; +} +#mod-quiz-edit .quizpagedelete img{ + background-color:#d6d6d6; +} +#mod-quiz-edit div.quizpage .pagecontent form#addquestion{ + background-color:#fff; +} +#mod-quiz-edit .questioncontentcontainer div.randomquestionqlist{ + background-color:#eee; + color:#777; +} +#mod-quiz-edit .questioncontentcontainer div.randomquestionqlist .totalquestionsinrandomqcategory{ + color:#000; +} +/*TODO: below applies to also question bank, so when +question bank is adapted to the new UI, add the appropriate +css id's of question bank*/ +#mod-quiz-edit .categoryinfo{ + background-color:#eee; + border-bottom:1px solid #bbb; +} +#mod-quiz-edit .paging{ + background-color:#ddd; +} +#mod-quiz-edit .questionsortoptions{ + background-color:#ddd; +} + +#mod-quiz-edit .paging a:hover{ + background-color:#eef; +} +#mod-quiz-edit div.questionbank{ + background-color:#e6e6ff; +} +#mod-quiz-edit .questionbank div.categoryquestionscontainer,.questionbank .categorysortopotionscontainer,.questionbank .categorypagingbarcontainer,.questionbank .categoryselectallcontainer{ + background-color:#FFF; +} +#mod-quiz-edit div.question div.content div.questioncontrols{ + background-color:#FFF; +} +#mod-quiz-edit div.editq div.question div.content{ + background-color:#fff; +} +#mod-quiz-edit .questionbankwindow div.header a{ + color:#FFF; +} + + /*** *** Modules: Resource ***/ @@ -1212,3 +1279,4 @@ color:#000; } + Index: theme/standard/styles_layout.css =================================================================== RCS file: /cvsroot/moodle/moodle/theme/standard/styles_layout.css,v retrieving revision 1.634 diff -u -r1.634 styles_layout.css --- theme/standard/styles_layout.css 18 Nov 2008 07:10:01 -0000 1.634 +++ theme/standard/styles_layout.css 19 Nov 2008 03:03:18 -0000 @@ -4245,20 +4245,6 @@ margin-bottom: 0.5em; } -#mod-quiz-edit #page .controls, -#mod-quiz-edit #page .quizattemptcounts -{ - text-align: center; -} -#mod-quiz-edit .quizquestions h2 { - margin-top: 0; -} -#mod-quiz-edit #showhidepagingcontrols { - margin-top: 0.7em; -} -#mod-quiz-edit #showhidepagingcontrols .singlebutton { - display: inline; -} .quizquestionlistcontrols { text-align: center; } @@ -4421,6 +4407,545 @@ display: block; margin: 0.5em 0; } +#mod-quiz-edit div.sideblock{ + float:right; + width:30%; + right:0.3em; + padding-bottom:0.5em; + display:block; +} + +#mod-quiz-edit div.quizcontents{ + float:left; + width:70%; + display:block; +} + +#mod-quiz-edit div.quizcontents,h2.main{ + clear:left; +} + +#mod-quiz-edit .addpage{ + clear:both; + padding-top:0.3em; + float:right; + margin-right:2em; +} + +#mod-quiz-edit h2.main{ + display:inline; + padding-right:1em; +} + +#mod-quiz-edit .statusdisplay{ + clear:both; + display:block; + border:0.2em #FFF solid; + margin-bottom:0.3em; + margin-right:1em; + margin-top:0.3em; + padding:0.1em; +} +#mod-quiz-edit div.quizpage{ + display:block; + clear:both; + width:100%; +} + +#mod-quiz-edit div.quizpage span.pagetitle{ + margin-top:0.3em; + float:left; + display:block; +} + +#mod-quiz-edit div.reorder .reordercontrols .moveselectedonpage{ + clear:right; + float:right; + padding:0.5em 0.3em; +} + +#mod-quiz-edit div.reorder .reordercontrols .addnewpagesafterselected,#mod-quiz-edit .repaginatecommand{ + float:right; + clear:right; + padding-right:1em; +} + +#mod-quiz-edit div.reorder .reordercontrols .deleteselected{ + float:right; + margin-right:1em; +} + +#mod-quiz-edit div.reorder .reordercontrols{ + clear:both; + padding-right:1em; + margin-top:0.5em; + padding-top:0.5em; + padding-bottom:0.5em; +} + +#mod-quiz-edit div.quizpage .pagecontent{ + margin-top:0.3em; + display:block; + float:left; + position:relative; + margin-left:0.3em; + border-left:solid #777 thin; + line-height:1.3em; + -webkit-border-radius:0.6em; + -webkit-border-radius-bottomleft:0; + -webkit-border-radius-topleft:0; + border-radius:0.6em; + border-radius-bottomleft:0; + border-radius-topleft:0; + width:88%; + padding:0 0 0.5em; +} + +#mod-quiz-edit div.question{ + clear:left; + width:100%; +} + +#mod-quiz-edit div.question div.qnum{ + display:block; + float:left; + width:1.4em; + padding-right:0.3em; + padding-left:0; + z-index:99; +} + +#mod-quiz-edit div.reorder div.question div.qnum{ + width:2.9em; + padding-top:0.1em; +} +/*edit tab*/ +#mod-quiz-edit div.editq div.question div.qnum{ + padding-top:0.2em; +} + +#mod-quiz-edit div.editq div.question{ + padding-top:0.3em; +} + +#mod-quiz-edit div.reorder div.question{ + padding-top:0.2em; +} + +#mod-quiz-edit div.question div.questioncontainer{ + background-color:#ffc; +} + +#mod-quiz-edit div.editq div.question div.content{ + width:87%; + float:left; + position:relative; + -webkit-border-radius:0.6em; + -webkit-border-radius-bottomleft:0; + -webkit-border-radius-topleft:0; + border-radius:0.6em; + border-radius-bottomleft:0; + border-radius-topleft:0; + line-height:1.4em; + padding:0.5em; +} + +#mod-quiz-edit .reorder div.question div.content{ + width:87%; + float:left; + background-color:#fff; + position:relative; + -webkit-border-radius:0.3em; + -webkit-border-radius-bottomleft:0; + -webkit-border-radius-topleft:0; + border-radius:0.3em; + border-radius-bottomleft:0; + border-radius-topleft:0; + line-height:1.2em; + padding:0.1em; +} + +#mod-quiz-edit div.question div.content div.points{ + top:0.5em; + border-left:#FFF solid 0.4em; + width:7.5em; + padding:0.2em; +} + +#mod-quiz-edit .questionbankwindow select#catmenu_jump{ + /* In Opera9, IE6 the width of the + select obeys the width of its content + by default. This prevents that. */ + width:100%; +} + +#mod-quiz-edit .questionbankwindow div.header{ + padding-top:0.2em; +} + +#randomquestiondialog_c select{ + width:100%; +} + + +#mod-quiz-edit div.question div.content div.points, + #mod-quiz-edit div.question div.content div.qorder{ + line-height:1em; + float:right; + max-width:30%; + position:absolute; + right:50px; + -webkit-border-radius:0.2em; + -webkit-border-radius-bottomleft:0; + -webkit-border-radius-topleft:0; + border-radius:0.2em; + border-radius-bottomleft:0; + border-radius-topleft:0; + z-index:999; + display:block; + margin:0; +} + + +#mod-quiz-edit div.question div.content .editicon{ + width:15px; +} + +#mod-quiz-edit .editq div.questioncontentcontainer div.singlequestion img{ + float:left; + padding-top:0.3em; + padding-right:0.3em; +} + + +#mod-quiz-edit div.question div.content .questionname, +#categoryquestions .questionname{ + white-space:nowrap; + text-overflow:ellipsis; + overflow:hidden; + zoom:1; + position:relative; + max-width:20%; + /*ie-only:*/ + text-overflow:ellipsis; + /*opera-only*/ + -o-text-overflow:ellipsis; +} +#mod-quiz-edit div.question div.content .singlequestion .questionname, +#mod-quiz-edit div.question div.content .singlequestion .questiontext{ + display:inline-block; +} + +#mod-quiz-edit div.editq div.question div.content .singlequestion a .questionname, +#mod-quiz-edit div.editq div.question div.content .singlequestion a .questiontext{ + float:left; +} + +#mod-quiz-edit .quizquestionlistcontrols{ + display:inline; +} + +#mod-quiz-edit div.question div.content .questiontext, +#categoryquestions .questiontext{ + -o-text-overflow:ellipsis; + text-overflow:ellipsis; + position:relative; + zoom:1; + padding-left:0.3em; + max-width:50%; + overflow:hidden; + white-space:nowrap; + text-overflow:ellipsis; +} + +#mod-quiz-edit div.quizpage .pagecontent .pagestatus{ + -webkit-border-radius-bottomright:0.3em; + -webkit-border-radius-topright:0.3em; + border-radius-bottomright:0.3em; + border-radius-topright:0.3em; + margin:0.3em; + padding:0.1em 0.1em 0.1em 0.3em; +} + +#mod-quiz-edit div.question div.content .questiontype{ + display:block; + clear:left; + float:left; +} + +#mod-quiz-edit div.question div.content .questionpreview{ + display:block; + float:left; + margin-left:0.3em; + padding-left:0.2em; + padding-right:0.2em; + background-color:#eee; +} + +#mod-quiz-edit div.question div.content div.quiz_randomquestion .questionpreview{ + display:inline; + float:none; +} + +#mod-quiz-edit div.question div.content div.questioncontrols{ + float:right; + width:45px; + position:absolute; + right:0.3em; + top:0; + z-index:999; + display:block; + padding:0.2em; +} + +#mod-quiz-edit div.question div.content div.questioncontrols img.upwithoutdown{ + padding-right:12px; + display:inline; +} + +#mod-quiz-edit .quizpagedelete{ + position:absolute; + top:0.2em; + right:0.2em; + display:inline; + z-index:999; +} + +#mod-quiz-edit .quizpagedelete img{ + background-color:#d6d6d6; + padding:0.5em; +} + +#mod-quiz-edit .pagecontrols{ + clear:both; + margin-left:0.5em; + padding-top:0.5em; +} + +#mod-quiz-edit .pagecontrols .singlebutton{ + float:left; +} + +#mod-quiz-edit div.quizpage .pagecontent form#addquestion{ + margin-right:1em; + -webkit-border-radius:0.2em; + border-radius:0.2em; + padding:0.3em; +} + +#mod-quiz-edit div.quizpage .pagecontent form.randomquestionform{ + padding-left:1em; +} + +#mod-quiz-edit div.quizpage .pagecontent form.randomquestionform div{ + /* it is a mystery why this has to be inline-table but + otherwise the layout gets screwed, even if + it is "inline" */ + display:inline-table; +} + +#mod-quiz-edit div.quizpage .pagecontent form.randomquestionform div input{ + display:inline; +} + +#mod-quiz-edit div.quizpage .pagecontent .adddescription{ + clear:left; + margin-top:0.3em; +} + +#mod-quiz-edit div.quizpage .pagecontent .addrandomquestion{ + margin-top:0.3em; +} + +/* a CSS class YUI container creates on the fly: */ +#mod-quiz-edit div#randomquestiondialog_c{ + width:90%; +} + +#mod-quiz-edit #repaginatedialog .hd{ + display:none; +} + +#mod-quiz-edit div#randomquestiondialog{ + display:none; +} + +#mod-quiz-edit div#randomquestiondialog_c .mform, +#mod-quiz-edit div#repaginatedialog .mform{ + margin-left:auto; + margin-right:auto; +} + +#mod-quiz-edit div.container div.generalbox{ + position:relative; + display:block; + border:0 none; + margin:0; + padding:0; +} + +#mod-quiz-edit .questioncontentcontainer div.randomquestionqlist{ + padding-left:0.2em; + padding-right:0.2em; + clear:both; + margin:0.5em; +} + + +#mod-quiz-edit .questioncontentcontainer div.randomquestionqlist ul{ + list-style-type:none; + margin:0; + padding:0; +} + + +#mod-quiz-edit .reorder .questioncontentcontainer .randomquestioncategory, +#mod-quiz-edit .reorder .questioncontentcontainer .randomquestionfromcategory, +#mod-quiz-edit .reorder div.question div.content .questionpreview{ + display:inline; + float:none; +} + +#mod-quiz-edit .reorder .questioncontentcontainer{ + position:relative; + overflow:hidden; + white-space:nowrap; +} + +#mod-quiz-edit .reorder .questioncontentcontainer .randomquestioncategory{ + overflow:hidden; + white-space:nowrap; +} + +#mod-quiz-edit .reorder fieldset{ + display:inline; +} + +#mod-quiz-edit .questioncontentcontainer div.randomquestionqlist ul li{ + clear:left; + width:100%; + overflow:hidden; + white-space:nowrap; +} + +#mod-quiz-edit .questioncontentcontainer div.randomquestionqlist ul li span{ + display:inline; +} + +/*start question bank*/ + +/*TODO: below applies to also question bank, so when +question bank is adapted to the new UI, add the appropriate +css id's of question bank*/ +#mod-quiz-edit .questionbankwindow .createnewquestion select, +#mod-quiz-edit .questionbankwindow #catmenu select{ + width:80%; +} +#mod-quiz-edit table#categoryquestions{ + width:100%; + overflow:hidden; + table-layout:fixed; +} + +#mod-quiz-edit table#categoryquestions td,#mod-quiz-edit table#categoryquestions th{ + overflow:hidden; + white-space:nowrap; +} + +#mod-quiz-edit table#categoryquestions col#qaction{ + width:20%; +} + +#mod-quiz-edit table#categoryquestions col#qextraactions{ + width:40px; +} + +#mod-quiz-edit table#categoryquestions .iconsmall{ + padding-left:5px; +} +#mod-quiz-edit .categoryinfo{ + padding:0.3em; +} + + + +#mod-quiz-edit .paging{ + margin-top:0; + margin-bottom:0; + display:block; +} + +#mod-quiz-edit .questionsortoptions{ + margin-top:0.3em; +} + +#mod-quiz-edit .pagingbottom{ + padding-bottom:0.3em; +} + +#mod-quiz-edit div.questionbank form .invisiblefieldset{ + clear:both; +} + +#mod-quiz-edit div.createnewquestion{ + padding-top:0.3em; + clear:left; +} + +#mod-quiz-edit .sideblock .content{ + padding:0; +} + +#mod-quiz-edit .questionbank .categorysortopotionscontainer{ + padding-top:0.5em; + margin-top:0.3em; +} + +#mod-quiz-edit .questionbank .categoryselectallcontainer{ + padding-bottom:0.5em; +} + +#mod-quiz-edit .questionbank div.categoryquestionscontainer, +#mod-quiz-edit .questionbank .categorysortopotionscontainer, +#mod-quiz-edit .questionbank .categorypagingbarcontainer, +#mod-quiz-edit .questionbank .categoryselectallcontainer{ + padding-left:0.3em; + padding-right:0.3em; +} + +#mod-quiz-edit .noquestionsincategory{ + clear:both; + padding-top:1em; + padding-bottom:1em; +} + +#mod-quiz-edit .modulespecificbuttonscontainer{ + padding-left:0.3em; + padding-right:0.3em; +} + +#mod-quiz-edit div#footer{ + clear:both; + padding-top:1em; +} + +#mod-quiz-edit #repaginatecommand{ + display:none; +} + +/*.usejs class is added via javascript so these will toggle if js is enabled*/ +#mod-quiz-edit .usejs #repaginatedialog{ + display:none; +} +#mod-quiz-edit .usejs #repaginatedialog .hd{ + display:block; +} +#mod-quiz-edit .usejs #repaginatedialog .bd{ + padding:1em; +} +#mod-quiz-edit .usejs .repaginatecommand #repaginatecommand{ + display:block; +} /*** *** Modules: Resource Index: theme/standard/styles_fonts.css =================================================================== RCS file: /cvsroot/moodle/moodle/theme/standard/styles_fonts.css,v retrieving revision 1.166 diff -u -r1.166 styles_fonts.css --- theme/standard/styles_fonts.css 18 Nov 2008 07:10:01 -0000 1.166 +++ theme/standard/styles_fonts.css 19 Nov 2008 03:03:17 -0000 @@ -1006,7 +1006,60 @@ text-decoration: underline; } -/*** +#mod-quiz-edit div.reorder .reordercontrols .moveselectedonpage{ + text-align:right; +} +#mod-quiz-edit div.question div.qnum{ + text-align:right; +} +#mod-quiz-edit div.reorder div.question div.qnum{ + text-align:right; + font-size:1em; +} +#mod-quiz-edit div.editq div.question div.qnum{ + font-size:1.5em; +} +#mod-quiz-edit .questionbankwindow div.header a{ + text-decoration:underline; +} +#mod-quiz-edit div.questioncontentcontainer a{ + text-decoration:underline; +} + +#mod-quiz-edit div.questioncontentcontainer div.singlequestion a{ + text-decoration:underline; +} +#mod-quiz-edit div.editq div.question div.content .singlequestion a .questionname,div.editq div.question div.content .singlequestion a .questiontext{ + text-decoration:underline; +} +#mod-quiz-edit div.question div.content .questiontext, +#categoryquestions .questiontext{ + font-weight:bold; +} +#mod-quiz-edit div.question div.content div.questioncontrols{ + text-align:right; +} +#mod-quiz-edit div.quizpage .pagecontent .pagestatus{ + font-weight:bold; +} +#mod-quiz-edit div.question div.content .questiontype{ + font-style:italic; +} +#mod-quiz-edit .questioncontentcontainer .randomquestioncategory{ + font-weight:bold; +} +#mod-quiz-edit .categoryinfofield{ + font-style:italic; +} +#mod-quiz-edit .categorynamefield{ + font-weight:bold; +} +#mod-quiz-edit .questionbankwindow div.header{ + font-weight:bold; +} + + + /*** *** Modules: Resource ***/ Index: theme/standard/styles_ie6.css =================================================================== RCS file: /cvsroot/moodle/moodle/theme/standard/styles_ie6.css,v retrieving revision 1.19 diff -u -r1.19 styles_ie6.css --- theme/standard/styles_ie6.css 4 Sep 2008 04:55:32 -0000 1.19 +++ theme/standard/styles_ie6.css 19 Nov 2008 03:03:17 -0000 @@ -69,3 +69,22 @@ #mod-quiz-review #middle-column { height: 1%; } +#mod-quiz-edit div.question div.content .questionname, +#categoryquestions .questionname{ + /*ie6 shows this as an arrow if this is not specified*/ + cursor: pointer; +} +#mod-quiz-edit #categoryquestions .questiontext{ + /*ie6 shows this as an arrow if this is not specified*/ + cursor: pointer; +} +#mod-quiz-edit div.tabtree a span img.iconsmall{ + display:none; +} + +#mod-quiz-edit div.question div.content .questiontext,#categoryquestions .questiontext{ + width:50%; +} +#mod-quiz-edit div.question div.content .questionname,#categoryquestions .questionname{ + width:20%; +} Index: theme/standard/styles_moz.css =================================================================== RCS file: /cvsroot/moodle/moodle/theme/standard/styles_moz.css,v retrieving revision 1.37 diff -u -r1.37 styles_moz.css --- theme/standard/styles_moz.css 4 Sep 2008 04:55:32 -0000 1.37 +++ theme/standard/styles_moz.css 19 Nov 2008 03:03:18 -0000 @@ -347,3 +347,32 @@ #quiznavigation .qnbutton { -moz-box-sizing: content-box; } +#mod-quiz-edit div.quizpage .pagecontent{ + -moz-border-radius:0.6em; + -moz-border-radius-bottomleft:0; + -moz-border-radius-topleft:0; +} +#mod-quiz-edit .reorder div.question div.content{ + + -moz-border-radius:0.3em; + -moz-border-radius-bottomleft:0; + -moz-border-radius-topleft:0; +} +#mod-quiz-edit div.editq div.question div.content{ + -moz-border-radius:0.6em; + -moz-border-radius-bottomleft:0; + -moz-border-radius-topleft:0; +} +#mod-quiz-edit div.question div.content div.points, + #mod-quiz-edit div.question div.content div.qorder{ + -moz-border-radius:0.2em; + -moz-border-radius-bottomleft:0; + -moz-border-radius-topleft:0; +} +#mod-quiz-edit div.quizpage .pagecontent .pagestatus{ + -moz-border-radius-bottomright:0.3em; + -moz-border-radius-topright:0.3em; +} +#mod-quiz-edit div.quizpage .pagecontent form#addquestion{ + -moz-border-radius:0.2em; +} \ No newline at end of file Index: lib/weblib.php =================================================================== RCS file: /cvsroot/moodle/moodle/lib/weblib.php,v retrieving revision 1.1170 diff -u -r1.1170 weblib.php --- lib/weblib.php 18 Nov 2008 10:17:27 -0000 1.1170 +++ lib/weblib.php 19 Nov 2008 03:03:14 -0000 @@ -1009,7 +1009,7 @@ * @todo Finish documenting this function
*/ function popup_form($common, $options, $formid, $selected='', $nothing='choose', $help='', $helptext='', $return=false, -$targetwindow='self', $selectlabel='', $optionsextra=NULL) { +$targetwindow='self', $selectlabel='', $optionsextra=NULL, $submitvalue='', $disabled=false) { global $CFG, $SESSION; static $go, $choose; /// Locally cached, in case there's lots on a page @@ -1018,16 +1018,23 @@ return ''; } - if (!isset($go)) { - $go = get_string('go'); + if (empty($submitvalue)){ + if (!isset($go)) { + $go = get_string('go'); + $submitvalue=$go; + } } - if ($nothing == 'choose') { if (!isset($choose)) { $choose = get_string('choose'); } $nothing = $choose.'...'; } + if ($disabled) { + $disabled = 'disabled="disabled"'; + } else { + $disabled = ''; + } // changed reference to document.getElementById('id_abc') instead of document.abc // MDL-7861 @@ -1046,16 +1053,16 @@ $selectlabel = ''; } - //IE and Opera fire the onchange when ever you move into a dropdwown list with the keyboard. + //IE and Opera fire the onchange when ever you move into a dropdown list with the keyboard. //onfocus will call a function inside dropdown.js. It fixes this IE/Opera behavior. //Note: There is a bug on Opera+Linux with the javascript code (first mouse selection is inactive), //so we do not fix the Opera behavior on Linux if (check_browser_version('MSIE') || (check_browser_version('Opera') && !check_browser_operating_system("Linux"))) { - $output .= '
'.$selectlabel.$button.''."\n"; } //Other browser else { - $output .= '
'.$selectlabel.$button.''."\n"; } if ($nothing != '') { @@ -1144,7 +1151,7 @@ $output .= ''; $output .= ''; $output .= '
'; - $output .= '
'; + $output .= '
'; $output .= ' + +'; +//apply CSS for when javascript is enabled +require_js('mod/quiz/editcss.js',true); +print_header_simple($pagetitle, '', $navigation, "", $localcss,true, + $questionbankmanagement.$strupdatemodule); +echo $localjs; +$mode = 'editq'; +$currenttab="edit"; +if($quiz_reordertool){ + $mode="reorder"; +} +include('tabs.php'); + +if($quiz_qbanktool){ + $showbank_inlinecss='display: none;'; + $bank_inlinecss='display: block;'; + $hidebank_inlinecss='display: inline;'; + $quizcontents_inlinecss=""; + +}else{ + $showbank_inlinecss='display: inline;'; + $bank_inlinecss='display: none;'; + $hidebank_inlinecss='display: none;'; + $quizcontents_inlinecss='width:100%;'; +} +print_side_block_start(get_string('questionbankcontents','quiz'). + ' ['.get_string("show"). + '] + ['.get_string("hide"). + '] + ', array("class"=>"questionbankwindow")); +echo '
'; +echo '
'; +echo '
'; +$cmoptions = new stdClass; +$cmoptions->hasattempts=$quiz_has_attempts; +quiz_question_showbank('editq', $contexts, $thispageurl, $cm, + $pagevars['qpage'], + $pagevars['qperpage'], $pagevars['qsortorder'], + $pagevars['qsortorderdecoded'], + $pagevars['cat'], $pagevars['recurse'], $pagevars['showhidden'], + $pagevars['showquestiontext'],$cmoptions); +echo '
'; +echo '
'; +echo '
'; +print_side_block_end(); + +if (!$quizname = $DB->get_field($cm->modname, 'name', array('id'=>$cm->instance))) { + print_error('cannotmodulename'); +} + +echo '
'; +$questionsperpagebool = ($quiz->questionsperpage < 1) ? 0 : 1; +if($questionsperpagebool){ + $repaginatingdisabledhtml='disabled="disabled"'; + $repaginatingdisabled=true; +}else{ + $repaginatingdisabledhtml=''; + $repaginatingdisabled=false; +} +if($quiz_reordertool){ + echo '
'; + echo '
'; +} +print_heading($pagetitle.": ".$quizname, 'left', 2); +helpbutton("editconcepts", get_string("basicideasofquiz","quiz"), "quiz", + true,get_string("basicideasofquiz","quiz")); + +$notifystring=""; +if($quiz_has_attempts){ + $string=get_string('cannoteditafterattempts', 'quiz'); + $string.='
' . + quiz_num_attempt_summary($quiz, $cm) . '
' ; + $notifystring.=notify($string,$style='notifyproblem', $align='center', $return=true); +} +if($questionsperpagebool && $quiz_reordertool){ + $string=get_string('questionsperpageselected', 'quiz'); + $updateurl=new moodle_url("$CFG->wwwroot/course/mod.php", + array("return"=>"true","update"=>$quiz->cmid, "sesskey"=>sesskey())); + $string.= ''; + $string.=get_string('updatethis', '', get_string('modulename', 'quiz')); + $string.='.'; + $notifystring.=notify($string,$style='notifyproblem', $align='center', $return=true); +} +if($quiz->shufflequestions && $quiz_reordertool){ + $string=get_string('shufflequestionsselected', 'quiz'); + $updateurl=new moodle_url("$CFG->wwwroot/course/mod.php", + array("return"=>"true","update"=>$quiz->cmid, "sesskey"=>sesskey())); + $string.= ''; + $string.=get_string('updatethis', '', get_string('modulename', 'quiz')); + $string.='.'; + $notifystring.=notify($string,$style='notifyproblem', $align='center', $return=true); +} +if(!empty($notifystring)){ + //TODO: make the box closable so it is not in the way + print_box_start(); + echo $notifystring; + print_box_end(); +} - print_footer($course); +if($quiz_reordertool){ + $perpage= array(); + $perpage[0] = get_string('allinone', 'quiz'); + for ($i=1; $i<=50; ++$i) { + $perpage[$i] = $i; + } + $gostring=get_string('go'); + echo '
'; + echo get_string("repaginatecommand","quiz"); + echo '
'; + echo '
'; + echo '
'; + echo $thispageurl->hidden_params_out(); + echo ''; + //YUI does not submit the value of the submit button so + //we need to add the value: + echo ''; + print_string('repaginate', 'quiz', + choose_from_menu($perpage, 'questionsperpage', + $quiz->questionsperpage, '', '', '', true,$repaginatingdisabled)); + echo '
'; + echo ' '; + echo '
'; +} +ob_start(); +$sumgrades = quiz_print_question_list($quiz, $thispageurl, true, + null, + $quiz_reordertool, $quiz_qbanktool, $quiz_has_attempts); + +if (!$DB->set_field('quiz', 'sumgrades', $sumgrades, array('id' => $quiz->instance))) { + print_error('cannotsetsumgrades', 'quiz'); +} + +$question_list=ob_get_contents(); +ob_end_clean(); +$tabindex=0; + +if(!$quiz_reordertool){ + quiz_print_grading_form($quiz,$thispageurl,$tabindex); +} +quiz_print_status_bar($quiz,$sumgrades); ?> +
+ +
+: +echo '
'; + +if(!$quiz_reordertool){ + // display category adding UI + ?> +
+
+ + +
+
display_randomquestion_user_interface(); +?>
+
+ \ No newline at end of file Index: lang/en_utf8/quiz.php =================================================================== RCS file: /cvsroot/moodle/moodle/lang/en_utf8/quiz.php,v retrieving revision 1.113 diff -u -r1.113 quiz.php --- lang/en_utf8/quiz.php 25 Sep 2008 08:22:00 -0000 1.113 +++ lang/en_utf8/quiz.php 19 Nov 2008 03:03:10 -0000 @@ -678,5 +678,44 @@ $string['youneedtoenrol'] = 'You need to enrol in this course before you can attempt this quiz'; $string['yourfinalgradeis'] = 'Your final grade for this quiz is $a.'; $string['zerosignificantfiguresnotallowed'] = 'The correct answer cannot have zero significant figures!'; - +$string['totalquestionsinrandomqcategory'] = 'Total of $a questions in category.'; +$string['selectquestiontype'] = ' -- Select question type -- '; +$string['adddescriptionlabel'] = 'Add description/label'; +$string['addrandomquestion'] = 'Add random question'; +$string['addrandomquestiontoquiz'] = 'Add random question to quiz $a'; +$string['parentcategory'] = 'Parent category'; +$string['selectcategory'] = 'Select category'; +$string['createcategoryfornewrandomquestion'] = 'Create a question category for the new random question'; +$string['qname'] = 'name'; +$string['qtypename'] = 'type, name'; +$string['age'] = 'age'; +$string['sortquestionsbyx'] = 'Sort questions by: $a'; +$string['addpagehere'] = 'Add page here'; +$string['questionbankmanagement'] = 'Question Bank management'; +$string['totalpoints'] = 'Total of grades'; +$string['quizwillopen'] = 'This quiz will open $a'; +$string['quizopenwillclose'] = 'This quiz is open, will close on $a at '; +$string['basicideasofquiz'] = 'Basic ideas of making quizzes'; +$string['noquestionsinquiz'] = 'There are no questions in this quiz.'; +$string['addquestion'] = 'Add question'; +$string['questiontextisempty'] = '[Empty question text]'; +$string['addrandomfromcategory'] = 'Add random questions from category'; +$string['fromcategory'] = 'from category'; +$string['questionbankcontents'] = 'Question Bank contents'; +$string['quizorderrandom'] = '* Order of quiz is shuffled'; +$string['quizordernotrandom'] = 'Order of quiz not shuffled'; +$string['repaginatecommand'] = 'Repaginate'; +$string['orderandpaging'] = 'Order and paging'; +$string['noquestionsonpage'] = 'Empty page'; +$string['orderingquiz'] = 'Order and paging'; +$string['moveselectedonpage'] = 'Move selected questions to page'; +$string['addnewpagesafterselected'] = 'Add new pages after selected questions'; +$string['reorderquestions'] = 'Reorder questions'; +$string['noquestionsnotinuse'] = 'This random question is not in use, since its category is empty.'; +$string['addnewquestionsqbank'] = 'Add questions to the category $a in the \'Question bank contents\' tool >>'; +$string['empty'] = 'Empty'; +$string['quizopened'] = 'This quiz is open.'; +$string['areyousuredeleteselected'] = 'Are you sure you want to delete the selected questions?'; +$string['questionsperpageselected'] = 'Questions per page has been set so the paging is currently fixed. As a result, the paging controls have been disabled. You can change this in '; +$string['shufflequestionsselected'] = '* Shuffle questions has been set so question order is random. As a result, the button Reorder questions has been disabled. You can change this in '; ?> Index: question/type/edit_question_form.php =================================================================== RCS file: /cvsroot/moodle/moodle/question/type/edit_question_form.php,v retrieving revision 1.21 diff -u -r1.21 edit_question_form.php --- question/type/edit_question_form.php 8 Oct 2008 10:27:38 -0000 1.21 +++ question/type/edit_question_form.php 19 Nov 2008 03:03:17 -0000 @@ -193,6 +193,10 @@ $mform->setType('returnurl', PARAM_LOCALURL); $mform->setDefault('returnurl', 0); + $mform->addElement('hidden', 'appendqnumstring'); + $mform->setType('appendqnumstring', PARAM_ALPHA); + $mform->setDefault('appendqnumstring', 0); + $buttonarray = array(); if (!empty($this->question->id)){ //editing / moving question Index: lang/en_utf8/help/quiz/editconcepts.html =================================================================== RCS file: lang/en_utf8/help/quiz/editconcepts.html diff -N lang/en_utf8/help/quiz/editconcepts.html --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ lang/en_utf8/help/quiz/editconcepts.html 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,25 @@ +

Basic ideas of making quizzes

+

The main concepts while managing quiz content (questions) are:

+
    +
  • Quiz and pages
  • +
  • Question bank and its categories
  • +
  • Random question
  • +
+

You can think of a quiz, in essence, to be like a +traditional pen&paper quiz (or an exam/test). It contains questions. +You can divide the questions in a quiz on several pages +or you can keep them all on one page. +With Moodle Quiz, you can also give the grading beforehand for the +questions in a quiz (as well as the total for the entire quiz).

+

When you create questions, they are stored in the Question +Bank. In the Question Bank you can create categories, which are similar +to folders. You can use them to create a hierarchy for organizing +questions, for example, by topic. When you create a question into +an exam, a copy of it is stored in the Question Bank. If you decide to +remove your question from an exam, it will still be intact in the +question bank until you delete it from there, too.

+

You can use Random Questions, if you want a question to +vary between different attempts students make at the quiz (for example, +to avoid cheating by means of students copying questions to each other). +Just create a random question in the quiz and add questions in the +category of the random question.

Index: mod/quiz/editcss.js =================================================================== RCS file: mod/quiz/editcss.js diff -N mod/quiz/editcss.js --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ mod/quiz/editcss.js 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,7 @@ +/** JavaScript for /mod/quiz/edit.php to be loaded in the header + * Adds a CSS class to display edit.php for users with JavaScript. + */ + YAHOO.util.Event.onDOMReady( + function(){ + YAHOO.util.Dom.addClass('quizcontentsblock', 'usejs'); + }); Index: mod/quiz/edit.js =================================================================== RCS file: mod/quiz/edit.js diff -N mod/quiz/edit.js --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ mod/quiz/edit.js 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,130 @@ +/** JavaScript for /mod/quiz/edit.php + */ + +YAHOO.namespace("cats.container"); +YAHOO.namespace("quiz.container"); +function init() { + YAHOO.util.Dom.setStyle('randomquestiondialog', 'display', 'block'); + YAHOO.cats.container.module = new YAHOO.widget.Module("module"); + YAHOO.cats.container.show = new YAHOO.widget.Module("show"); + YAHOO.cats.container.hide = new YAHOO.widget.Module("hide"); + YAHOO.cats.container.module.render(); + YAHOO.util.Event.addListener("show", "click", YAHOO.cats.container.module.show, + YAHOO.cats.container.module, true); + YAHOO.util.Event.addListener("show", "click", + function(e){ + YAHOO.cats.container.hide.show; + // for some reason YUI sets element display "block" so we have to reverse that: + hideel.setStyle("display", "inline"); + //TODO: get sURL from the phpdata object somehow + var sUrl=""; + var transaction = YAHOO.util.Connect.asyncRequest("GET", sUrl, null, null); + YAHOO.util.Event.stopEvent(e); + }, YAHOO.cats.container.hide, true); + YAHOO.util.Event.addListener("show", "click", YAHOO.cats.container.show.hide, YAHOO.cats.container.show, true); + YAHOO.util.Event.addListener("hide", "click", YAHOO.cats.container.module.hide, YAHOO.cats.container.module, true); + YAHOO.util.Event.addListener("hide", "click", + function(e){ + YAHOO.cats.container.show.show; + // for some reason YUI sets element display + // to "block" so we have to reverse that: + showel.setStyle("display", "inline"); + var sUrl="$surl"; + var transaction = YAHOO.util.Connect.asyncRequest("GET", sUrl, null, null); + YAHOO.util.Event.stopEvent(e); + }, YAHOO.cats.container.show, true); + + YAHOO.util.Event.addListener("hide", "click", YAHOO.cats.container.hide.hide, YAHOO.cats.container.hide, true); + + // Instantiate the Dialog + /* zIndex must be way above 99 to be above the active quiz tab*/ + YAHOO.quiz.container.randomquestiondialog = new YAHOO.widget.Dialog("randomquestiondialog", + { + constraintoviewport : true, + visible : false, + modal:true, + width : "100%", + iframe:true, + zIndex:1000, + fixedcenter : true, + close: true, + draggable: true, + dragOnly: true, + postmethod: "form" + + } ); + //show the dialog and depending on from which form (corresponding + // a specific quiz page) it was triggered, set the value of the form's + // rqpage input element to the form number + YAHOO.util.Event.addListener(this.dialog_listeners, "click", + function(e){ + this.show(); + var rbutton = YAHOO.util.Event.getTarget(e); + var rbform = YAHOO.util.Dom.getAncestorByClassName(rbutton,"randomquestionform"); + //this depends on the fact that the element hierarchy be: + //
[input elements]
+ var rbformelements = YAHOO.util.Dom.getChildren + (YAHOO.util.Dom.getFirstChild(rbform)); + var rqpage=YAHOO.util.Dom.get("rform_qpage"); + + /* + //this should work, it doesn't, no time to debug. + var rqpagehiddenel=YAHOO.util.Dom.getFirstChildBy(rbformelements,function(el) { + //alert("infunc"); + var result=YAHOO.util.Dom.hasClass(el,"addonpage_formelement"); + //if (result) alert ("yes"); else alert("no"); + return result; + }); + //no element in rqpagehiddenel + //rqpage.value=rqpagehiddenel.value.value; + */ + + //this works instead + for (var i = 0; i < rbformelements.length; i++) { + if(YAHOO.util.Dom.hasClass(rbformelements[i],"addonpage_formelement")){ + //why is this not rqpage.value.value, the first "value" being the element property + // and the second the value of that property? I don't understand. + rqpage.value=rbformelements[i].attributes.value.value; + } + } + YAHOO.util.Event.stopEvent(e); + }, YAHOO.quiz.container.randomquestiondialog, + YAHOO.quiz.container.randomquestiondialog, true); + YAHOO.quiz.container.randomquestiondialog.render(); +// Instantiate the Dialog + YAHOO.quiz.container.repaginatedialog = new YAHOO.widget.Dialog("repaginatedialog", + { + modal:true, + width : "100%", + iframe:true, + zIndex:1000, + fixedcenter : true, + visible : false, + close: true, + draggable: true, + dragOnly: true, + constraintoviewport : true, + postmethod: "form" + } ); +YAHOO.util.Event.addListener("repaginatecommand", "click", + function(e){ + YAHOO.util.Dom.setStyle('repaginatedialog', 'display', 'block'); + this.show(); + }, YAHOO.quiz.container.repaginatedialog, + YAHOO.quiz.container.repaginatedialog, true); + YAHOO.quiz.container.repaginatedialog.render(); + +} + + +YAHOO.util.Event.addListener(window, "load", init,phpGenerated,true); +YAHOO.util.Dom.setStyle('repaginatedialog', 'display', 'block'); + +//TODO: take this inside the init function to make sure +//YAHOO.cats.container.module is defined when run +if (YAHOO.cats.container.module && quiz_qbanktool){ + YAHOO.cats.container.module.hide(); + YAHOO.cats.container.show.show(); + showel.setStyle("display", "inline"); + YAHOO.cats.container.hide.hide(); +} Index: mod/quiz/addrandom.php =================================================================== RCS file: mod/quiz/addrandom.php diff -N mod/quiz/addrandom.php --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ mod/quiz/addrandom.php 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,73 @@ +dirroot.'/mod/quiz/editlib.php'); + require_once($CFG->dirroot."/question/category_class.php"); + + list($thispageurl, $contexts, $cmid, $cm, $quiz, $pagevars) = question_edit_setup('editq', true); + + $defaultcategoryobj = question_make_default_categories($contexts->all()); + $defaultcategoryid=$defaultcategoryobj->id; + $defaultcategorycontext=$defaultcategoryobj->contextid; + $defaultcategory="$defaultcategoryid,$defaultcategorycontext"; + + $qcobject = new question_category_object( + $pagevars['cpage'], + $thispageurl, + $contexts->having_one_edit_tab_cap('categories'), + $defaultcategoryid, + $defaultcategory, + null, + $contexts->having_cap('moodle/question:add')); + + //setting the second parameter of process_randomquestion_formdata to true causes it to redirect on success + //TODO: process if returns false? + quiz_process_randomquestion_formdata($qcobject,true, $cmid); + + //these params are only passed from page request to request while we stay on this page + //otherwise they would go in question_edit_setup + $quiz_page = optional_param('quiz_page', 0, PARAM_SEQUENCE); + $returnurl = optional_param('returnurl', 0, PARAM_LOCALURL); + + $strquizzes = get_string('modulenameplural', 'quiz'); + $strquiz = get_string('modulename', 'quiz'); + $streditingquestions = get_string('editquestions', "quiz"); + $streditingquiz = get_string('editinga', 'moodle', $strquiz); + + // Get the course object and related bits. + if (! $course = $DB->get_record("course", array("id"=> $quiz->course))) { + error("This course doesn't exist"); + } + // TODO: Log this visit. + /* + add_to_log($cm->course, 'quiz', 'editquestions', + "view.php?id=$cm->id", "$quiz->id", $cm->id); + */ + //you need mod/quiz:manage in addition to question capabilities to access this page. + require_capability('mod/quiz:manage', $contexts->lowest()); + // Print basic page layout. + + $strupdatemodule = has_capability('moodle/course:manageactivities', $contexts->lowest()) + ? update_module_button($cm->id, $course->id, get_string('modulename', 'quiz')) + : ""; + $navigation = build_navigation($streditingquiz, $cm); + print_header_simple($streditingquiz, '', $navigation, "", "", true, $strupdatemodule); + + if (!$quizname = $DB->get_field($cm->modname, 'name', array('id'=> $cm->instance))) { + error('Cannot get the module name in build navigation.'); + } + + print_heading(get_string("addrandomquestiontoquiz","quiz",$quizname), 'left', 2); + + $qcobject->display_randomquestion_user_interface(); + + print_footer($course); +?> Index: question/category_form_randomquestion.php =================================================================== RCS file: question/category_form_randomquestion.php diff -N question/category_form_randomquestion.php --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ question/category_form_randomquestion.php 1 Jan 1970 00:00:00 -0000 @@ -0,0 +1,50 @@ +libdir.'/formslib.php'); + +class question_category_edit_form_randomquestion extends moodleform { + + function definition() { + global $CFG, $DB; + $mform =& $this->_form; + + $contexts = $this->_customdata['contexts']; + $currentcat = $this->_customdata['currentcat']; +//-------------------------------------------------------------------------------- + $mform->addElement('header', 'categoryheader', get_string('createcategoryfornewrandomquestion', 'quiz')); + + $questioncategoryel = $mform->addElement('questioncategory', 'parent', get_string('parentcategory', 'quiz'), + array('contexts'=>$contexts, 'top'=>true, 'currentcat'=>$currentcat, 'nochildrenof'=>$currentcat)); + $mform->setType('parent', PARAM_SEQUENCE); + if (1 == $DB->count_records_sql("SELECT count(*) + FROM {question_categories} c1, + {question_categories} c2 + WHERE c2.id = ? + AND c1.contextid = c2.contextid", array($currentcat))){ + //TODO: Tim? why does the above evaluate true, breaking the form? + // and more importantly, if this is a valid situation, how should we react, + // that is, what does this mean? + //$mform->hardFreeze('parent'); + } + $mform->setHelpButton('parent', array('categoryparent', get_string('parent', 'quiz'), 'question')); + + $mform->addElement('text','name', get_string('name'),'maxlength="254" size="50"'); + $mform->setDefault('name', ''); + $mform->addRule('name', get_string('categorynamecantbeblank', 'quiz'), 'required', null, 'client'); + $mform->setType('name', PARAM_MULTILANG); + + $mform->addElement('hidden', 'info', ''); + $mform->setType('info', PARAM_MULTILANG); + + +//-------------------------------------------------------------------------------- + $this->add_action_buttons(false, get_string('addrandomquestion', 'quiz')); +//-------------------------------------------------------------------------------- + $mform->addElement('hidden', 'id', 0); + $mform->setType('id', PARAM_INT); + //TODO: Tim: is this questionable? to add a hidden field right from a get parameter? + $mform->addElement('hidden', 'addonpage', optional_param("addonpage_form", 0, PARAM_SEQUENCE), 'id="rform_qpage"'); + $mform->setType('addonpage', PARAM_SEQUENCE); + } +} +?>